package com.cy.pj.arithmetic.controller;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @RestControllerAdvice相当于@ControllerAdvice + @ResponseBody
 * 异常处理级别：方法内try...catch... > 类中异常处理方法@ExceptionHandler > 全局类
 */
@RestControllerAdvice
public class GlobalExceptionHandlser {
    @ExceptionHandler(ArithmeticException.class)
    public String doHandlerArithmeticException(ArithmeticException e) {
        return "exception msg is " + e.getMessage();
    }
}
